﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;

namespace Bot.Domain.Categories.Service
{
    public class OveragePackageDomainService : IOveragePackageDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, OveragePackage> _repository;

        public OveragePackageDomainService(IRepository<Guid, OveragePackage> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public OveragePackage Create(OveragePackage overagePackage)
        {
            if (overagePackage.Id == Guid.Empty)
            {
                overagePackage.Id = Guid.NewGuid();
            }
            return _repository.Create(overagePackage);
        }

        public OveragePackage Get(Guid id)
        {
            return _repository.Get(id);
        }

        public OveragePackage Update(OveragePackageUpdateBo bo)
        {
            OveragePackage overagePackage = _repository.Get(bo.Id);
            overagePackage.Id = bo.Id;
            overagePackage.OverageMessageQuota = bo.OverageMessageQuota;
            overagePackage.OverageUnitPrice = bo.OverageUnitPrice;

            _repository.Update(overagePackage);

            return overagePackage;

        }

        public IEnumerable<OveragePackage> List()
        {
            return _repository.ListAll();
        }

        public void Delete(Guid id)
        {
            OveragePackage overagePackage = _repository.Get(id);

            _repository.Delete(overagePackage);

        }
    }
}
